import re

import  requests
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
option = Options()
option.add_argument("--headless")
option.add_argument("--disable-gpu")
service =Service(r"F:\桌面\win_r\浏览器驱动\chrome/chromedriver.exe")
driver =webdriver.Chrome(options=option,service=service)
url = "https://w.linovelib.com/novel/2013/catalog"
res = requests.get(url)
text =res.text
list = re.findall("<li class=\"chapter-li jsChapter\"><a href=\".*\" class=\"chapter-li-a \"><span class=\"chapter-index \">.*</span></a></li>",text)
file2 = open("F:/桌面/章节.txt","a",encoding="utf-8")
for i in list :
    text = i.replace("<li class=\"chapter-li jsChapter\"><a href=\"","").replace("\" class=\"chapter-li-a \"><span class=\"chapter-index \">","     ").replace("</span></a></li>","")
    file2.write(text+"\n")



